package com.jumper.property.comparer.starter;


import com.jumper.property.comparer.core.annotations.UniqueKey;
import com.jumper.property.comparer.core.enums.LogTable;
import com.jumper.property.comparer.core.support.AbstractBatchLogManager;
import com.jumper.property.comparer.core.support.AbstractLogManager;
import com.jumper.property.comparer.core.support.LogRepository;

import java.util.Collection;
import java.util.Set;
import java.util.function.Function;

/**
 *
 */
public interface LoggerManager {

    /**
     * 实例
     */
    LoggerManager INSTANCE = new LoggerConfiguration();

    /**
     * 获取单条数据处理Manager
     */
    <T> AbstractLogManager<T> getLogger(LogTable type);

    /**
     * 获取单条数据处理Manager, 如果为空,抛异常
     */
    <T> AbstractLogManager<T> loadLogger(LogTable type);

    /**
     * 获取批处理数据Manager
     */
    <K extends UniqueKey<T>, T> AbstractBatchLogManager<K, T> getMultiLogger(LogTable type);

    /**
     * 获取批处理数据Manager, 如果为空,抛异常
     */
    <K extends UniqueKey<T>, T> AbstractBatchLogManager<K, T> loadMultiLogger(LogTable type);

    /**
     * 注册单条数据处理Manager
     */
    <T> void registerLogger(LogTable type, Function<T, Object> getOneFunc, LogRepository repository);

    /**
     * 注册单条数据处理Manager
     */
    <T> void registerLogger(LogTable type, AbstractLogManager<T> manager);

    /**
     * 注册批处理Manager
     */
    <K extends UniqueKey<T>, T> void registerMultiLogger(LogTable type, Function<Collection<T>, Set<K>> getListFunc, LogRepository repository);

    /**
     * 注册批处理Manager
     */
    <K extends UniqueKey<T>, T> void registerMultiLogger(LogTable type, AbstractBatchLogManager<K, T> manager);
}
